<cfcomponent displayname="libAccess gateway" hint="">
	
	<cffunction name="init" access="public" returntype="libAccessGateway" output="false" displayname="libAccess Constructor" hint="I initialize a libAccess.">
		<cfargument name="datasourceSettings" type="any" required="true" />
		
		<cfset variables.dsn = arguments.datasourceSettings.getConfigSetting("dsn") />
		<cfset variables.dbtype = arguments.datasourceSettings.getConfigSetting("dbtype") />

		<cfreturn this />
	</cffunction>

	<cffunction name="getAll" access="public" returntype="query" output="false" displayname="" hint="">

		<cfset var libAccessSelect = 0 />
		<cfquery name="libAccessSelect" datasource="#variables.dsn#">
			SELECT * 
			FROM	libAccess	
		</cfquery>

		<cfreturn libAccessSelect/>
	</cffunction>
	
	<cffunction name="getCheckAccess" access="public" returntype="query" output="false" displayname="" hint="">
		<cfargument name="libID" type="numeric">
		<cfargument name="userID" type="string">
		
		
		<cfset var libAccessSelect = 0 />
		<cfquery name="libAccessSelect" datasource="#variables.dsn#">
			SELECT * 
			FROM	libAccess
			WHERE	userID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.userID#">
					AND libID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.libID#">
		</cfquery>

		<cfreturn libAccessSelect/>
	</cffunction>	
	
	<cffunction name="deleteByUserID" access="public" returntype="void" output="false" displayname="" hint="">
		<cfargument name="userid" default="" required="true" type="string">
		<cfset var deleteLibAccessByUserID = 0 />

		<cfquery name="deleteLibAccessByUserID" datasource="#variables.dsn#">
			DELETE	FROM	libAccess	WHERE userid = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.userid#">
		</cfquery>

	</cffunction>

</cfcomponent>